package com.hevs.samplewebapp.client.bean;

import com.google.gwt.core.client.JsArray;
/**
 * Abstract class to transform JSON into JavaScript object
 * <p>Provide methods to change an array of medical data, a token and an array of users into javascript object equivalent</p>
 * @author Lionel Rey
 * @date 14.03.2012
 */
public abstract class JSONHelper {
	// Method to convert the string of JSON into JavaScript object.
	/**
	 * Convert the String array of medical data into Javascript array
	 * @param json
	 * 	Response string format of the server
	 * @return
	 * 	transformation of the String into Javascript array
	 */
	public static final native JsArray<MedicalDataJson> asArrayOfMedicalData(String json) /*-{ return eval(json); }-*/;
	
	/**
	 * Convert the string of token into a Javascript String 
	 * @param json
	 * 	Response String format of the server
	 * @return
	 * 	transformation of the String into a Javascript String
	 */
	public static final native TokenJson asToken(String json)/*-{ eval('var res = ' + json); return res; }-*/;

	/**
	 * Convert the String array of doctors into Javascript array
	 * @param json
	 * 	Response string format of the server
	 * @return
	 * 	transformation of the String into Javascript array
	 */
	public static final native JsArray<DoctorJson> asArrayOfDoctor(String json) /*-{ return eval(json); }-*/;
	
	/**
	 * Convert the String array of users into Javascript array
	 * @param json
	 * 	Response string format of the server
	 * @return
	 * 	transformation of the String into Javascript array
	 */
	public static final native JsArray<UserDataJson> asArrayOfUserData(String json) /*-{ return eval(json); }-*/;
}
